﻿using Colorful.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Colorful.Apps.ERP.Models
{
    /// <summary>
    /// 订单表
    /// </summary>
    public class Order : BaseId
    {
        /// <summary>
        /// 产品列表：手动添加需要有个多选界面，列表中要要具体到“规格”
        /// </summary>
        public List<OrderProduct> Products { get; set; }
        /// <summary>
        /// 客户Id（下拉框选择客户表：Client）
        /// </summary>
        public string ClientId { get; set; }
        /// <summary>
        /// 订单状态（RadioGroup组件单选）
        /// </summary>
        public OrderState State { get; set; }
        /// <summary>
        /// 订单合计（自动计算）
        /// </summary>
        public decimal Price { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        public long ByOrder { get; set; }

        #region Ignore
        /// <summary>
        /// 订单Id
        /// </summary>
        public List<string> ProductIds
        {
            get
            {
                return this.Products.Select(a => a.ProductId).ToList();
            }
        }
        #endregion
    }
    /// <summary>
    /// 订单产品（根据选择的产品自动生成）
    /// </summary>
    public class OrderProduct
    {
        /// <summary>
        /// 编号
        /// </summary>
        public string Id { get; set; }
        /// <summary>
        /// 展示产品Id（ProductShow表的Id）
        /// </summary>
        public string ProductId { get; set; }
        /// <summary>
        /// 售出价格（手填）
        /// </summary>
        public decimal Price { get; set; }
        /// <summary>
        /// 售出数量（手填）
        /// </summary>
        public int Amount { get; set; }
        /// <summary>
        /// 折扣
        /// </summary>
        public decimal Discount { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
    }
}
